subroutine wmbej_t1fj_iefbm(wmbej, iabci, & 
              t1, fae, icore, fact1, fact2)
!
use mod_iop
use mod_size
use mod_ioff
use mod_orbit
implicit none
!
real*4, intent(in),managed :: wmbej(*)
real*4, intent(in),managed :: iabci(*), fae(*)
!
real*4, intent(inout),managed :: t1(*), icore(*)
real*8, intent(inout) :: fact1, fact2
!
integer :: i, j, a, b, nsize, i0, i1, i2, nsize2
integer :: iofftmp
integer, external :: idsymsoc, irpdso
real*8 fact
real*8, external :: dnrm2, nrm2so
!this is to do wmbej = wmbej - t1(f,j)*<ef||bm>
i0 = 1
i1 = i0 + nvvvo*isd
i2 = i1 + nvvoo*isd
!====EMBJ AAAA
! T1(F,J)*<EF||BM>
call myicopyso(iabci(ioi5(2)), icore(i1), nioi52)
call isymtrso(iabci(ioi5(2)), icore(i0), vrta, vrta, 1, 1, vrta, popa, 1, 0, 1) 
call axpyso(nioi52, -1.d0, icore(i0), 1, icore(i1), 1) 
call itranspso(icore(i1), icore(i0), vrta, vrta, 1, vrta, popa, 1, 1) 
call VpqrmVms_to_Vpqrs(icore(i0), t1(ifvo(1)), 1, 1, vrta, & 
              vrta, popa, 1, vrta, popa, icore(i1), 1, 1.d0, 0.d0) 
!--tmp(BMEJ)
call sstgenso(icore(i1), icore(i2), nsize, vrta, popa, vrta, popa, & 
              icore, 1, '3214')
nsize = idsymsoc(1, vrta, vrta, 1, popa, popa, 1)
nsize = ioi4(2)-ioi4(1)
call axpyso(nioi41, fact1, icore(i2), 1, wmbej(ioi4(1)), 1)
!
!--sum(BMEJ)=f(BE)
call sstgenso(icore(i1), icore(i2), nsize, vrta, popa, vrta, popa, &
               icore, 1, '2413')
call sumpq(1, popa, vrta, vrta, 1, icore(i2), icore(i1))
nsize2 = irpdso(1, vrta, vrta, 1)
iofftmp = ifvv(1)
call axpyso(nsize2, fact2, icore(i1), 1, fae(iofftmp), 1)
!
!====EmBj ABAB
! <Ef||Bm>*T1(f,j)
call itranspso(iabci(ioi5(2)), icore(i0), vrta, vrtb, 1, vrta, popb, 1, 1) 
call VpqrmVms_to_Vpqrs(icore(i0), t1(ifvo(1)), 1, 1, vrtb, & 
              vrta, popb, 1, vrta, popb, icore(i1), 1, 1.d0, 0.d0) 
!--tmp(BmEj)
call sstgenso(icore(i1), icore(i2), nsize, vrta, popb, vrta, popb, & 
              icore, 1, '3214')
call axpyso(nioi42, fact1, icore(i2), 1, wmbej(ioi4(2)), 1)
!
!--sum(BmEj)=f(BE)
call sstgenso(icore(i1), icore(i2), nsize, vrta, popb, vrta, popb, &
               icore, 1, '2413')
call sumpq(1, popb, vrta, vrta, 1, icore(i2), icore(i1))
call axpyso(irpdso(1, vrta, vrta, 1), fact2, icore(i1), 1, fae(ifvv(1)), 1)
!===EMbj AABB
! <Ef|bM>*T1(fj)=-<fE|bM>*t1(fj)
call isymtrso(icore(i0), icore(i1), vrtb, popa, 1, 0, vrtb, vrta, 1, 1, 1) 
nsize = idsymsoc(1, vrta, vrtb, 1, vrtb, popa, 1)
call myicopyso(icore(i1), icore(i0), nsize) 
call VpqrmVms_to_Vpqrs(icore(i0), t1(ifvo(1)), 1, 1, vrtb, &
              vrtb, popa, 1, vrta, popb, icore(i1), 1, 1.d0, 0.d0)
!--tmp(bM,Ej)
call sstgenso(icore(i1), icore(i2), nsize, vrtb, popa, vrta, popb, &
              icore, 1, '3214')
call axpyso(nioi45, fact2, icore(i2), 1, wmbej(ioi4(5)), 1)

return
end
